package com.sctvcloud.longchang.ui.activities;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.longchang.R;
import com.sctvcloud.longchang.base.BaseActivity;
import com.sctvcloud.longchang.ui.fragment.TvFragment;

import butterknife.BindView;
import butterknife.ButterKnife;


public class TVActivity extends FragmentActivity {
    @BindView(R.id.title_top_layout_edit)
    protected CustomFontTextView share;

    @BindView(R.id.title_top_logo_layout)
    protected LinearLayout title_top_logo_layout;
    @BindView(R.id.title_top_title)
    protected CustomFontTextView title_top_title;
    @BindView(R.id.title_top_layout_back)
    protected ImageView title_top_layout_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tv);
        ButterKnife.bind(this);

        title_top_logo_layout.setVisibility(View.GONE);
        title_top_title.setVisibility(View.VISIBLE);

        if(getIntent().getIntExtra(BaseActivity.EX_ID,0)==1){
            title_top_title.setText(getText(R.string.text_radio));
        }else {
            title_top_title.setText(getText(R.string.text_live));
        }


        title_top_layout_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        share.setVisibility(View.GONE);

        if(!TextUtils.isEmpty(getIntent().getStringExtra(BaseActivity.EX_URL))){

            Bundle bundle = new Bundle();
            TvFragment fragment = new TvFragment();
            bundle.putString(BaseActivity.EX_URL, getIntent().getStringExtra(BaseActivity.EX_URL));
            bundle.putInt(BaseActivity.EX_ID, getIntent().getIntExtra(BaseActivity.EX_ID,0));

        //    fragment.setChannelUrl(getIntent().getStringExtra(BaseActivity.EX_URL));
            fragment.setArguments(bundle);
            getSupportFragmentManager()
                    .beginTransaction()
                    .add(R.id.fragment_container,fragment)
                    .commit();



        }



    }

}
